package cn.openea.perpartner.expert.web.service.impl;

import cn.openea.perpartner.expert.web.domain.dto.SignupDto;
import cn.openea.perpartner.expert.web.mapper.SignupMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.openea.perpartner.expert.web.domain.entity.Signup;
import cn.openea.perpartner.expert.web.service.ISignupService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 专家协作报名表(Signup)表服务实现类
 *
 * @author Weird077
 * @since 2023-06-19 11:45:59
 */
@Service("signupService")
public class SignupServiceImpl extends ServiceImpl<SignupMapper, Signup> implements ISignupService {

    @Override
    public List<Signup> selectSignupList(SignupDto dto) {
        LambdaQueryWrapper<Signup> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Signup::getTaskNum, dto.getTaskNum());
        wrapper.eq(Signup::getStatus, dto.getStatus());
        wrapper.orderByAsc(Signup::getCreateTime);
        return list(wrapper);
    }

    @Override
    public Signup selectSignupInfo(SignupDto dto) {
        LambdaQueryWrapper<Signup> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(Signup::getTaskNum, dto.getTaskNum());
        wrapper.eq(Signup::getUserId, dto.getUserId());
        return getOne(wrapper, false);
    }

    @Override
    public int selectSignupCount(String taskNum) {
        return (int) count(Wrappers.<Signup>lambdaQuery().eq(Signup::getTaskNum, taskNum));
    }
}

